<?php
/**
 * Created by PhpStorm.
 * User: CuYen
 * Date: 5/22/14
 * Time: 4:18 PM
 */
if(! defined('BASEPATH')) exit("No direct script access allowed'");
class Register extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
    }
    //
    public function index()
    {
        $this->load->view("register/index");
    }
    //
    public function register_account()
    {
        $submit = $this->input->post("submit", TRUE);
        
        if(isset($submit))
        {
            $username = $this->input->post("username", TRUE);
            // password
            $password = $this->input->post("password", TRUE);
            // re_password
            $re_password = $this->input->post("re_password", TRUE); // XSS security
            // email
            $email = $this->input->post("email", TRUE);
            // gender
            $gender = $this->input->post("gender", TRUE);

            //Upload
            $config['upload_path'] = FCPATH . 'uploads/';
            $config['allowed_types'] = 'gif|jpg|png|doc|docx';
            $config['max_size'] = '100';
            $config['max_width']  = '1024';
            $config['max_height']  = '768';
            // load library upload
            $this->load->library('upload', $config);
            if ( ! $this->upload->do_upload('file'))
            {
                $error = array('error' => $this->upload->display_errors());

                echo "Upload fail!";
                var_dump($error);
            }
            else
            {
                $data = array('upload_data' => $this->upload->data());
                echo "Upload success";
                var_dump($data);
            }

        }
    }

}